#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

int n;
string s;

ll cont(int x) {
    return x * (x + 1) / 2;
}

int main() {
    cin >> n;

    int p = 1;
    int m = n;
    while (m > 0) {
        // 找一个数x, 使得x个7的贡献不超过m, x+1个7的贡献超过m
        int x = 1;
        while (cont(x) <= m) x++;

        x--;
        // 塞上x个7,1个p
        for (int i = 1; i <= x; i++) {
            s += "7";
            p = p * 10 % 7; // 中间塞的东西不能凑出7的倍数
        }
        s += p + '0';

        // m去掉x个7的贡献
        m -= cont(x);
    }
    cout << s.substr(0, s.size() - 1) << endl;

}